from django.db import models


# Create your models here.
# 用户 Account  username email password register_date
class Account(models.Model):
    username = models.CharField("账号", max_length=64, unique=True)
    email = models.EmailField("邮箱", unique=True)
    password = models.CharField("密码", max_length=255)
    register_date = models.DateTimeField("注册时间", auto_now_add=True)
    signature = models.CharField("签名", max_length=255, null=True)


# 文章 Article   title content  pub_date
class Article(models.Model):
    title = models.CharField("标题", max_length=512)
    content = models.TextField("内容")
    account = models.ForeignKey("Account", on_delete=models.CASCADE)
    pub_date = models.DateTimeField("发布时间", auto_now_add=True)
    tags = models.ManyToManyField("Tag", null=True)


# 标签  Tag  name add_date
class Tag(models.Model):
    name = models.CharField("名称", unique=True, max_length=128)
    add_date = models.DateTimeField(auto_now_add=True)
